Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Include directive</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Include_directive"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Include_directive rootpage-Include_directive skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Include directive</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>An <b>include directive</b> instructs a <a href="Text_processing" title="Text processing">text file processor</a> to replace the directive text with the content of a specified file.
</p><p>The act of including may be logical in nature. The processor may simply process the include file content at the location of the directive without creating a combined file.
</p><p>Different processors may use different syntax. The <a href="C_preprocessor" title="C preprocessor">C preprocessor</a> (used with <a href="C_(programming_language)" title="C (programming language)">C</a>, <a href="C%2B%2B" title="C++">C++</a> and in other contexts) defines an include directive as a line that starts <code>#include</code> and is followed by a file specification. <a href="COBOL" title="COBOL">COBOL</a> defines an include directive indicated by <code>copy</code> in order to include a <b>copybook</b>.
</p><p>Generally, for C/C++ the include directive is used to include a <b>header file</b>, but can include any file. Although relatively uncommon, it is sometimes used to include a <b>body file</b> such as a .c file.
</p><p>The include directive can support <a href="Encapsulation_(object-oriented_programming)" class="mw-redirect" title="Encapsulation (object-oriented programming)">encapsulation</a> and <a href="Code_reuse" title="Code reuse">reuse</a>. Different parts of a system can be segregated into logical groupings yet rely on one another via file inclusion. C and C++ are designed to leverage include while also optimizing build time by allowing <a href="Declaration_(computer_programming)" title="Declaration (computer programming)">declaration</a> separate from <a href="Implementation" title="Implementation">implementation</a>. The included information can be minimized to only declarations.
</p><p>As directly including file content has significant drawbacks, such as excessive boilerplate or type/language syntax unawareness, newer languages have been designed without an include directive. Languages such as <a href="Java_(programming_language)" title="Java (programming language)">Java</a> and <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> support <a href="Modular_programming" title="Modular programming">modularization</a> via an <b>import</b> concept that allows a package or module to use the assets of another module at a conceptual level by loading the associated <a href="Java_class_file" title="Java class file">Java class file</a> or C# <a href="Dynamic-link_library" title="Dynamic-link library">DLL</a> as necessary; not by including text. Compiled languages, such as <a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a> and <a href="D_(programming_language)" title="D (programming language)">D</a>, simply link all <a href="Object_files" class="mw-redirect" title="Object files">object files</a> at compile time, and C++ also introduced <code>import</code> to import modules.
</p><p>Although C# has the ability to use some preprocessor directives similar to those of the C preprocessor, it does not contain the <code>#include</code> directive.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2></div>
<div class="mw-heading mw-heading3"><h3 id="C/C++">C/C++</h3></div>
<p>Both C and C++ (pre-C++20) are typically used with the C preprocessor that replaces a <code>#include</code> directive line with the content of the file specified. A file path is either enclosed in double quotes (i.e. <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */


.mw-parser-output .monospaced{font-family:monospace,monospace}


/* end https://en.wikipedia.org/ */
</style><span class="monospaced">"xyz.h"</span>) or angle brackets (i.e. <span class="monospaced">&lt;xyz.h&gt;</span>).<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> Some preprocessors locate the include file differently based on the enclosing delimiters; treating a path in double-quotes as relative to the including file and a path in angle brackets as located in one of the directories of the configured system search path.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p><p>Example include statements:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="c1">// include the C standard header 'stdio.h'; probably is a file with that name</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdio.h&gt;</span><span class="c1"> </span>
<span class="c1">// include the C++ standard header 'vector'; may or may not be a file</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;vector&gt;</span>
<span class="c1">// include a custom header file named 'user_defined.h'</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">"user_defined.h"</span>
</pre></div>
<p>The include directive allows for the development of code <a href="Library_(computing)" title="Library (computing)">libraries</a> that:
</p>
<ul><li>ensure that everyone uses the same version of a data layout definition or procedural code throughout a program</li>
<li>easily cross-reference where components are used in a system</li>
<li>easily change programs when needed (only one file must be edited)</li>
<li>save time by reusing data layouts</li></ul>
<div class="mw-heading mw-heading4"><h4 id="Example">Example</h4></div>
<p>Given two C source files. One defines a function <code>add()</code> and another uses the function. Without using an include directive, the consuming file can declare the function locally as a <a href="Function_prototype" title="Function prototype">function prototype</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="nf">add</span><span class="p">(</span><span class="kt">int</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="p">);</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">triple</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">x</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">add</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">add</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">));</span>
<span class="p">}</span>
</pre></div>
<p>One drawback of this approach is that the function prototype must be present in each file that calls <code>add()</code>. Another drawback is that if the signature changes, then each consuming file needs to be updated. Putting the prototype in a single, separate file avoids these issues. If the prototype is moved to a header file <code>add.h</code>, the using source file becomes:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="cp">#include</span><span class="w"> </span><span class="cpf">"add.h"</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">triple</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">x</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">add</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">add</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">));</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading4"><h4 id="Header_file">Header file</h4></div>
<p>In C and C++, a <b>header file</b> is a <a href="Source_code" title="Source code">source code</a> file that allows <a href="Programmer" title="Programmer">programmers</a> to separate elements of a <a href="Codebase" title="Codebase">codebase</a> – often into reusable, logically related groupings.
</p><p>A header file <a href="Forward_declaration" title="Forward declaration">declares</a> programming elements such as <a href="Function_(computer_programming)" title="Function (computer programming)">functions</a>, <a href="Class_(computer_science)" class="mw-redirect" title="Class (computer science)">classes</a>, <a href="Variable_(computer_science)" title="Variable (computer science)">variables</a>, and preprocessor <a href="Macro_(computer_science)" title="Macro (computer science)">macros</a>. A header file allows the programmer to use programming elements in multiple body files based on the common declaration in the header file. Declarations in a header file allow body files to use implementations without including the implementation code directly. The header keeps the interface separate from the <a href="Class_implementation_file" title="Class implementation file">implementation</a>.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p><p>Compilation errors may occur if multiple header files include the same file. One solution is to avoid including files in header files – possibly requiring excessive include directives in body files. Another solution is to use an <a href="Include_guard" title="Include guard">include guard</a> in each header file.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p>The <a href="C_standard_library" title="C standard library">C standard library</a> is declared as a collection of header files. The <a href="C%2B%2B_standard_library" class="mw-redirect" title="C++ standard library">C++ standard library</a> is similar, but the declarations may be provided by the compiler without reading an actual file.
</p><p>C standard header files are named with a <code>.h</code> <a href="File_name_extension" class="mw-redirect" title="File name extension">file name extension</a>, as in <code class="mw-highlight mw-highlight-lang-c++ mw-content-ltr" dir="ltr"><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;stdio.h&gt;</span></code>. Typically, custom C header files have the same extension. Custom C++ header files tend to have more variety of extensions, including <code>.hpp</code>, <code>.h++</code> and <code>.hh</code>.
</p><p>A C++ standard library name in angle brackets (i.e. <span class="monospaced">&lt;vector&gt;</span>) results in declarations being included but may not be from a file.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Header_unit">Header unit</h4></div>
<p>Since <a href="C%2B%2B20" title="C++20">C++20</a>, C++ supports import semantics via the <i>header unit</i>, that is, separate translation units synthesized from a header.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> They are meant to be used as a transitional state towards total adoption of modules.
</p><p><code>import</code>, as of <a href="C%2B%2B26" title="C++26">C++26</a>, is not a preprocessor directive. It is thus not handled by the C preprocessor. <code>import</code> does not copy code into a file like <code>#include</code>, but rather links the translation unit during compile time.
</p><p>Example:
</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr"><pre><span class="k">import</span><span class="w"> </span><span class="o">&lt;</span><span class="n">stdio</span><span class="p">.</span><span class="n">h</span><span class="o">&gt;</span><span class="p">;</span><span class="w"> </span><span class="c1">// supporting this is optional</span>
<span class="k">import</span><span class="w"> </span><span class="o">&lt;</span><span class="n">vector</span><span class="o">&gt;</span><span class="p">;</span><span class="w"> </span><span class="c1">// supporting this is mandated by the standard</span>
<span class="k">export</span><span class="w"> </span><span class="k">import</span><span class="w"> </span><span class="s">"user_defined.h"</span><span class="p">;</span>
</pre></div>
<p>Header units are provided for all the C++ standard library headers.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Modules">Modules</h4></div>
<p>Since C++20, <a href="Modules_(C%2B%2B)" title="Modules (C++)">modules</a> were introduced and is imported using <code>import</code>. These have the same semantics to import as header units, but have finer grained control of exports. They must be marked <code>module</code> and each symbol must be marked <code>export</code> or be in a <code>export</code> block to be accessible by importing. The semantics of an <code>import</code> statement are:
</p>
<pre>export<sub>optional</sub> import module_name;
</pre>
<p>As of <a href="C%2B%2B23" title="C++23">C++23</a>, the <a href="C%2B%2B_standard_library" class="mw-redirect" title="C++ standard library">C++ standard library</a> can be imported as a module by writing <code class="mw-highlight mw-highlight-lang-c++ mw-content-ltr" dir="ltr"><span class="k">import</span><span class="w"> </span><span class="n">std</span><span class="p">;</span></code>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Embed">Embed</h4></div>
<p>Added in <a href="C23_(C_standard_revision)" title="C23 (C standard revision)">C23</a> and <a href="C%2B%2B26" title="C++26">C++26</a>, the <code>#embed</code> directive is similar to the <code>#include</code> directive but is more appropriate for including/embedding binary resources into source code.
</p>
<div class="mw-heading mw-heading3"><h3 id="Objective-C">Objective-C</h3></div>
<p><a href="Objective-C" title="Objective-C">Objective-C</a>, like C, also uses header files and has an <code>#include</code> directive. However, it also has a <code>#import</code> directive, which behaves the same as <code>#include</code>, the only difference being that <code>#import</code> guarantees the inclusion of the file will never happen more than once, without the use of <a href="Include_guard" title="Include guard"><span class="monospaced">#include</span> guards</a> or <a href="Pragma_once" title="Pragma once"><span class="monospaced">#pragma once</span></a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="COBOL">COBOL</h3></div>
<p><a href="COBOL" title="COBOL">COBOL</a> (and also <a href="RPG_IV" class="mw-redirect" title="RPG IV">RPG IV</a>) allows programmers to copy copybooks into the source of the program – which is similar to including but allows for replacing text. The COBOL keyword for inclusion is <code>COPY</code>, and replacement is done using the <code>REPLACING ... BY ...</code> clause. An include directive has been present in COBOL since COBOL 60, but changed from the original <code>INCLUDE</code><sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> to <code>COPY</code> by 1968.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Fortran">Fortran</h3></div>
<p><a href="Fortran" title="Fortran">Fortran</a> does not require header files <i>per se</i>. However, Fortran 90 and later have two related features: <code>include</code> statements and modules. The former can be used to share a common file containing procedure interfaces, much like a C header, although the specification of an interface is not required for all varieties of Fortran procedures. This approach is not commonly used; instead, procedures are generally grouped into modules that can then be referenced with a <code>use</code> statement within other regions of code. For modules, header-type interface information is automatically generated by the compiler and typically put into separate module files, although some compilers have placed this information directly into object files. The language specification itself does not mandate the creation of any extra files, even though module procedure interfaces are almost universally propagated in this manner.
</p>
<div class="mw-heading mw-heading3"><h3 id="Haskell">Haskell</h3></div>
<p>The <a href="Haskell" title="Haskell">Haskell</a> language, which can use the C preprocessor by writing <code class="mw-highlight mw-highlight-lang-haskell mw-content-ltr" dir="ltr"><span class="cm">{-# LANGUAGE CPP #-}</span></code>, has access to the <code>#include</code> directive.
</p>
<div class="mw-heading mw-heading3"><h3 id="Pascal">Pascal</h3></div>
<p>Most <a href="Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a> compilers support the <code>$i</code> or <code>$include</code> compiler directive, in which the <code>$i</code> or <code>$include</code> directive immediately follows the start of a comment block in the form of
</p>
<ul><li><code>{$i <i>filename.pas</i>}</code></li>
<li><code>(*$I <i>filename.inc</i>*)</code></li>
<li><code>{$include <i>filename.inc</i>}</code></li>
<li><code>(*INCLUDE <i>filename.pas</i>*)</code></li></ul>
<p>Where the <code>$i</code> or <code>$include</code> directive is not <a href="Case_sensitivity" title="Case sensitivity">case sensitive</a>, and <i>filename.pas</i> or <i>filename.inc</i> is the name of the file to be included. (It has been common practice to name Pascal's include files with the <a href="Filename_extension" title="Filename extension">extension</a> <b>.inc</b>, but this is not required.) Some compilers, to prevent unlimited recursion, limit invoking an include file to a certain number, prohibit invoking itself or any currently open file, or are limited to a maximum of one include file at a time, e.g. an include file cannot include itself or another file. However, the program that includes other files can include several, just one at a time.
</p>
<div class="mw-heading mw-heading3"><h3 id="PHP">PHP</h3></div>
<p>In <a href="PHP" title="PHP">PHP</a>, the <code>include</code> directive causes another PHP file to be included and evaluated.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> Similar commands are <code>require</code>, which upon failure to include will produce a <a href="Fatal_exception" class="mw-redirect" title="Fatal exception">fatal exception</a> and halt the script,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> and <code>include_once</code> and <code>require_once</code>, which prevent a file from being included or required again if it has already been included or required, avoiding the C's double inclusion problem.
</p>
<div class="mw-heading mw-heading3"><h3 id="Other_languages">Other languages</h3></div>
<p>Other notable languages with an include directive:
</p>
<ul><li><code>include ...</code> (<a href="Fortran" title="Fortran">Fortran</a>, <a href="Microsoft_Macro_Assembler" title="Microsoft Macro Assembler">MASM</a>)</li>
<li><code>&lt;!--#include ... --&gt;</code> (HTML <a href="Server_Side_Includes" title="Server Side Includes">SSI</a>)</li>
<li><code>var ... = require("...")</code> (JavaScript with <a href="CommonJS" title="CommonJS">CommonJS</a>)</li>
<li><code>&lt;%@ include ...&nbsp;%&gt;</code> (<a href="JavaServer_Pages" class="mw-redirect" title="JavaServer Pages">JSP</a>)</li>
<li><code>{$I ...}</code> (<a href="UCSD_Pascal" title="UCSD Pascal">UCSD Pascal</a>, <a href="Turbo_Pascal" title="Turbo Pascal">Turbo Pascal</a>)</li>
<li><code>%include ...</code> (<a href="PL/I" title="PL/I">PL/I</a>)</li>
<li><code>/COPY <i>QCPYLESRC</i>,<i>QBC</i></code> (RPG IV – first argument is the filename, second argument is the copybook)</li>
<li><code>local ... = require("...")</code> (<a href="Lua_(programming_language)" class="mw-redirect" title="Lua (programming language)">Lua</a>)</li>
<li><code>let my_str = include_str!("spanish.in");</code> (<a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a>)<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></li></ul>
<p>Modern languages (e.g. <a href="Haskell_(programming_language)" class="mw-redirect" title="Haskell (programming language)">Haskell</a> and <a href="Java_(programming_language)" title="Java (programming language)">Java</a>) tend to avoid the include directive construct, preferring <a href="Modular_programming" title="Modular programming">modules</a> and import/export semantics. Some of these languages (such as Java and <a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a>) do not use forward declarations and, instead, identifiers are recognized automatically from source files and read directly from <a href="Dynamic_library" title="Dynamic library">dynamic library</a> symbols (typically referenced with <code>import</code> or <code>using</code> directives).
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Application_programming_interface" class="mw-redirect" title="Application programming interface">Application programming interface</a>&nbsp;– Connection between computers or programs<span style="display:none" class="category-annotation-with-redirected-description">Pages displaying short descriptions of redirect targets</span></li>
<li><a href="Class_implementation_file" title="Class implementation file">Class implementation file</a>&nbsp;– File implementing the methods of a class</li>
<li><a href="Header-only" title="Header-only">Header-only</a></li>
<li><a href="Interface_Definition_Language" class="mw-redirect" title="Interface Definition Language">Interface Definition Language</a>&nbsp;– Computer language used to describe a software component's interface<span style="display:none" class="category-annotation-with-redirected-description">Pages displaying short descriptions of redirect targets</span></li>
<li><a href="File_inclusion_vulnerability" title="File inclusion vulnerability">File inclusion vulnerability</a>&nbsp;– Type of web vulnerability</li>
<li><a href="Modular_programming" title="Modular programming">Modular programming</a>&nbsp;– Organizing code into modules</li>
<li><a href="One_Definition_Rule" title="One Definition Rule">One Definition Rule</a>&nbsp;– Rule of programming language C++</li>
<li><a href="Pragma_once" title="Pragma once">#pragma once</a>&nbsp;– Preprocessor directive in C and C++</li>
<li><a href="Precompiled_header" title="Precompiled header">Precompiled header</a>&nbsp;– Optimized type of file in computer programming</li>
<li><a href="Modules_(C%2B%2B)" title="Modules (C++)">Modules (C++)</a>&nbsp;– Modular translation unit in C++</li>
<li><a href="Transclusion" title="Transclusion">Transclusion</a>&nbsp;– Including one data set inside another automatically</li>
<li><a href="Unity_build" title="Unity build">Unity build</a>&nbsp;– Technique to speed up C/C++ project builds</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">C11 standard, 6.10.2 Source file inclusion, pp. 164–165</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFStallman1992" class="citation web cs1"><a href="Richard_Stallman" title="Richard Stallman">Stallman, Richard M.</a> (July 1992). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120904041038/http://docs.freebsd.org/info/cpp/cpp.pdf">"The C Preprocessor"</a> <span class="cs1-format">(PDF)</span>. Archived from <a rel="nofollow" class="external text" href="http://docs.freebsd.org/info/cpp/cpp.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 4 September 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">19 February</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">
<cite id="CITEREFAlan_Griffiths2005" class="citation web cs1">Alan Griffiths (2005). <a rel="nofollow" class="external text" href="http://accu.org/index.php/journals/269">"Separating Interface and Implementation in C++"</a>. ACCU<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-05-07</span></span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFPike1989" class="citation cs2"><a href="Rob_Pike" title="Rob Pike">Pike, Rob</a> (21 Feb 1989), <a rel="nofollow" class="external text" href="http://doc.cat-v.org/bell_labs/pikestyle"><i>Notes on programming in C</i></a>, Cat-v document archive<span class="reference-accessdate">, retrieved <span class="nowrap">9 Dec</span> 2011</span></cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">C11 standard, 7.1.2 Standard headers, p. 181, footnote 182: "A header is not necessarily a source file, nor are the <code>&lt;</code> and <code>&gt;</code> delimited sequences in header names necessarily valid source file names.</span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1103r3.pdf">"Merging Modules - P1103R3"</a> <span class="cs1-format">(PDF)</span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1502r1.html">"P1502R1 - Standard library header units for C++20"</a>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20140212200223/http://bitsavers.trailing-edge.com/pdf/codasyl/COBOL_Report_Apr60.pdf">"COBOL Initial Specifications for a COmmon Business Oriented Language"</a> <span class="cs1-format">(PDF)</span>. <a href="United_States_Department_of_Defense" title="United States Department of Defense">Department of Defense</a>. April 1960. p.&nbsp;IX-9. Archived from <a rel="nofollow" class="external text" href="http://bitsavers.trailing-edge.com/pdf/codasyl/COBOL_Report_Apr60.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 12 February 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">11 February</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation book cs1">"The COPY Statement". <a rel="nofollow" class="external text" href="https://archive.org/details/codasylcoboljour00conf"><i>CODASYL COBOL Journal of Development 1968</i></a>. July 1969. <a href="LCCN_(identifier)" class="mw-redirect" title="LCCN (identifier)">LCCN</a>&nbsp;<a rel="nofollow" class="external text" href="https://lccn.loc.gov/73601243">73601243</a>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.php.net/manual/en/function.include.php">"include"</a>. <i>php.net</i>. The PHP Group<span class="reference-accessdate">. Retrieved <span class="nowrap">20 February</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.php.net/manual/en/function.require.php">"require"</a>. <i>php.net</i>. The PHP Group<span class="reference-accessdate">. Retrieved <span class="nowrap">20 February</span> 2014</span>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/std/macro.include_str.html">"include_str in std - Rust"</a>. <i>doc.rust-lang.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">4 July</span> 2025</span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://www.gamedev.net/articles/programming/general-and-gameplay-programming/organizing-code-files-in-c-and-c-r1798">Organizing Code Files (the potential pitfalls and guidelines for using header files in C++)</a></li>
<li><a rel="nofollow" class="external text" href="http://www.eventhelix.com/RealtimeMantra/HeaderFileIncludePatterns.htm">C++ header file inclusion rules</a></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-29" href="https://en.wikipedia.org/wiki/?title=Include_directive&amp;oldid=1303206962">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>